﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Microsoft.Practices.EnterpriseLibrary.Security;
using Microsoft.Practices.EnterpriseLibrary.Security.AzMan;
using System.Security.Principal;

namespace AzMan.WebService
{
	/// <summary>
	/// Summary description for Service1
	/// </summary>
	[WebService(Namespace = "http://tempuri.org/")]
	[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
	[System.ComponentModel.ToolboxItem(false)]
	// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
	// [System.Web.Script.Services.ScriptService]
	public class Service1 : System.Web.Services.WebService
	{

		[WebMethod]
		public bool HelloWorld(string rule)
		{
			IAuthorizationProvider provider = AuthorizationFactory.GetAuthorizationProvider("AzMan Provider");
			IPrincipal principal = (WindowsPrincipal)HttpContext.Current.User;
			return provider.Authorize(principal, rule);
		}

		[WebMethod]
		public object[] GetAllowablePermissions(string context)
		{
			string location = "msxml://C:/WorkDir/Personal/guesshoo/trunk/Personal/AzMan.Sample/Sample.xml";
			FooProvider obj= new FooProvider(location, "Acme.Limited", "FooBar.Security", "");
			IPrincipal principal = (WindowsPrincipal)HttpContext.Current.User;

			return	obj.foo((WindowsIdentity) principal.Identity);

		}
	}
}
